package StringAlgorithms;

import java.util.Scanner;

class Solver1732
{	String trm;
	String[] Pat;
	char[] ori,Ans;
	
	public void Input()
	{	Scanner in=new Scanner(System.in);
		ori=in.nextLine().toCharArray();trm=in.nextLine();
		Pat=trm.split(" ");
		Ans=new char[ori.length];
	}
	private int[] KMPtable(char[] pat)
	{	int cur=2,cnd=0;
		int[] T=new int[pat.length];
		T[0]=-1;if (pat.length>=2) T[1]=0;
		while (cur<pat.length)
			if (pat[cur-1]==pat[cnd])
			{	cnd++;T[cur]=cnd;cur++;
			}
			else if (cnd>0) cnd=T[cnd];
			else
			{	T[cur]=0;cur++;
			}
		return T;
	}
	private int KMP(char[] pat,char[] text,int st)
	{	int i=0;
		int[] T=KMPtable(pat);
		while (st+i<text.length)
			if (text[st+i]==pat[i])
			{	if (i==pat.length-1) return st;
				i++;
			}
			else
			{	st=st+i-T[i];
				if (T[i]!=-1) i=T[i]; else i=0;
			}
		return -1;
	}
	public void Solve()
	{	Input();
		int mark=0,cur=0;
		for (String pat:Pat)
		{	int tmp=KMP(pat.toCharArray(),ori,cur);
			if (tmp!=-1)
			{	for (int i=mark;i<tmp;i++) Ans[i]=(ori[i]==' '?' ':'_');
				for (int i=0;i<pat.length();i++) Ans[tmp+i]=ori[tmp+i];
				mark=tmp+pat.length();cur=mark+1;
			}
			else
			{	System.out.println("I HAVE FAILED!!!");
				return;
			}
		}
		for (int i=mark;i<ori.length;i++) Ans[i]=(ori[i]==' ')?' ':'_';
		System.out.println(new String(Ans));
	}
}
public class P1732
{	public static void main(String[] args)
	{	Solver1732 solver=new Solver1732();
		solver.Solve();
	}
}
